using System;
using System.Collections;
using System.Data;

namespace Sedna.Core.Controller.Configurations
{
	public class DataTableBasedColumnControlEnabler : IDataGridColumnControlEnabler
	{
		private string dataField;

		private string enableCode = "Y";

		public string DataField
		{
			set { dataField = value; }
		}

		public string EnableCode
		{
			set { enableCode = value; }
		}

        public bool CheckIfEnabled(IDataGridColumnConfiguration columnConfiguration, object dataRow, IExecutionContext executionContext)
		{
			DataRowView drv = dataRow as DataRowView;
			if(drv == null)
			{
				throw new NotSupportedException("only DataRowView grid dataRow is supported");
			}
			object value = drv[dataField];
			return enableCode.Equals(value);
		}

        public bool CheckIfVisible(IDataGridColumnConfiguration columnConfiguration, object dataRow, IExecutionContext executionContext)
		{
			return true;
		}
	}
}
